#include<bits/stdc++.h>
using namespace std;
int n,a[200010];
int h[1000010];
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int T;
    cin>>T;
    while(T--){
        int ans=0;
        cin>>n;
        memset(h,0,sizeof(h));
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            h[a[i]]++;
        }
        for(int i=1;i<=n;i++)
        {
            if(h[a[i]]>1)ans+=a[i];
            h[a[i]]=0;
        }
        cout<<ans<<endl;
    }
    return 0;
}
